-
Couldn't load subscription status.
- Fork 13.9k
Improve bootstrap import error handling and warning clarity #148147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Updated Python version checks and error handling in x.py.
|
rustbot has assigned @Mark-Simulacrum. Use |
This comment has been minimized.
This comment has been minimized.
Improve bootstrap import error handling and warning clarity
|
This comment has been minimized.
This comment has been minimized.
If you run x.py from a different location, it will still be able to locate src/bootstrap. x.py looks relative to it's own location.
I don't see the point in this. This error can't happen unless you changed any of the python code. And if you do, the builtin python exception message is fine.
What user invocation? Can you show the warning that would be printed before and after this PR? |
|
Thanks for the feedback!
You're absolutely right — I verified that
Good point. I agree that this situation would only happen if the bootstrap code itself is broken, in which case Python’s native traceback is indeed clearer. I’ll revert that change as well.
Sure! Here’s an example of the difference. Before ( After ( The goal was to remove the internal file reference ( If maintainers prefer keeping |
|
I don't feel like we want to land this, the current error handling is sufficient and these changes don't address any real problem as far as I see |
This comment has been minimized.
This comment has been minimized.
|
Thanks for the feedback! I understand this doesn't address a critical need. |
|
In any case, I see this is your pull request, thanks for trying to contribute! A good place to start is by looking through issues with labels like |
x.py: Improve bootstrap import error handling and warning clarity
This change improves developer experience when invoking
x.pyin misconfigured environments.Summary
This pull request improves the startup behavior of
x.pyby providing clearerand more user-friendly error handling, without changing any functional behavior
or Python version requirements.
Details
Improved error message:
If the
src/bootstrapdirectory is missing (for example, when runningx.pyfrom an unexpected location), the script now exits with a clear,actionable message instead of failing with a less informative traceback.
Cleaner warning output:
The
stacklevelfor Python version warnings has been changed from1to2,ensuring that the warning message correctly points to the user's invocation
rather than an internal line within the script.
Graceful import handling:
The
import bootstrapstatement is now wrapped in atry/exceptblock toprovide a friendlier message if the module cannot be imported.
Rationale
These small improvements make it easier for contributors to understand and fix
environment misconfigurations during Rust’s bootstrap process, especially for
new contributors building from source. The change does not alter any
existing functionality, Python version logic, or fallback behavior.
Testing
./x.py checkand./x.py buildcontinue to work as expected.src/bootstrapdirectory produces the new clear error message.Notes
Example output with missing directory:
Maintainers: This is a small developer-experience improvement and should be safe to merge without affecting CI or bootstrap logic.